package com.kgc.rb.controller;

import com.kgc.rb.dto.RbResult;
import com.kgc.rb.service.LocalGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class GoodsController {

    @Autowired
    private LocalGoodsService localGoodsService;
    /**
     * 查询商品信息
     * @param id 商品编号
     * @return
     */
    @RequestMapping(value="/v/queryGoodsById",method= RequestMethod.POST)
    public RbResult queryGoodsById(String id) throws Exception{
        RbResult rbResult = localGoodsService.queryGoodsById(id);
        return rbResult;
    }

    /**
     * 抢购商品
     * @param token
     * @param goodsId 商品编号
     * @return
     * @throws Exception
     */
    @RequestMapping(value="/v/sendQgGoodsMessage",method=RequestMethod.POST)
    public RbResult sendQgGoodsMessage(String token,String goodsId)throws Exception{
        RbResult rbResult = localGoodsService.sendQgGoodsMessage(token,goodsId);
        return rbResult;
    }


    @RequestMapping(value="/v/flushResult",method=RequestMethod.POST)
    public RbResult flushResult(String token,String goodsId) throws Exception{
        RbResult rbResult = localGoodsService.flushUserRbGoodsResult(token,goodsId);
        return rbResult;
    }
}
